package com.neiquan.weiguan.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;

import com.neiquan.weiguan.R;
import com.neiquan.weiguan.presenter.ChannelPresenter;
import com.neiquan.weiguan.utils.Constant;

import net.neiquan.applibrary.utils.LogC;

import org.haitao.common.utils.SharedPreferencesUtil;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * 作者 : hjb
 * 时间 : 2016/4/25.
 */
public class WelcomeActivity extends AppCompatActivity {
    @InjectView(R.id.img_welcome)
    ImageView mImgWelcome;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);  //全屏
        setContentView(R.layout.activity_welcome);
        ButterKnife.inject(this);
        boolean firstLogin = SharedPreferencesUtil.getBoolean(this, Constant.SHAREDPREFERENCES_FIRSTLOGIN);
        if (firstLogin) {
            ChannelPresenter channelPresenter = new ChannelPresenter(this);
            channelPresenter.initDefaultChannel();
            SharedPreferencesUtil.add(WelcomeActivity.this, Constant.SHAREDPREFERENCES_FIRSTLOGIN, false);
        }
        AlphaAnimation animation = new AlphaAnimation(1.0f, 1.0f);
        animation.setDuration(3000);
        mImgWelcome.setAnimation(animation);
        animation.start();
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
    }
}
